package com.spj.aopTest;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author :spj
 * @Date:2022/3/28
 * @description:
 */
@Aspect
@Component
public class MyAop {
    @Pointcut("execution(* *(..))")
    public void point(){

    }
    @Before("point()")
    public void myBefore(JoinPoint joinpoint){
        System.out.println("前置通知：日志打印开始……");
        System.out.println("对应目标类是："+joinpoint.getTarget());
        System.out.println("对应目标类的方法是："+joinpoint.getSignature().getName());
    }
    @AfterReturning("point()")
    public void afterReturing(JoinPoint joinpoint){
        System.out.println("后置通知：事务提交开始……");
        System.out.println("对应目标类是："+joinpoint.getTarget());
        System.out.println("对应目标类的方法是："+joinpoint.getSignature().getName());

    }
    @After("point()")
    public void after(JoinPoint joinpoint){
        System.out.println("最终通知：最终提交开始……");
        System.out.println("对应目标类是："+joinpoint.getTarget());
        System.out.println("对应目标类的方法是："+joinpoint.getSignature().getName());

    }
}
